﻿using Newtonsoft.Json;
using PhysicalExamination5.Interface.DataMaintenance;
using PhysicalExamination5.Model.DataMaintenance;
using PhysicalExamination5.Model.PhysicalExamination;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace PhysicalExamination5.Service.DataMaintenance
{
    public class SKeShiWeiHu : IKeShiWeiHu
    {
        private readonly ISqlSugarClient db;
        public SKeShiWeiHu(ISqlSugarClient db)
        {
            this.db = db;
        }
        /// <summary>
        /// 科室维护添加
        /// </summary>
        /// <param name="KeShiAddClass"></param>
        /// <returns></returns>
        public string PostKeShiAdd(KeShiAddClass KeShiAddClass, string YuanQuQianZhui)
        {
            int nret = 0; string strFanHuiZhi = ""; bool BolShiFouChengGong = false; int iShunXu = 0; string strSql = "";
            try
            {
                Logger.Singleton.Debug($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:接收参数【{KeShiAddClass}】");

                #region 数据校验

                if (string.IsNullOrEmpty(KeShiAddClass.strKeShiMingCheng))
                {
                    nret = 1;
                    strFanHuiZhi = "科室名称为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiAddClass.strKeShiLeiXing))
                {
                    nret = 1;
                    strFanHuiZhi = "科室类型为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiAddClass.strShiFouQiYong))
                {
                    nret = 1;
                    strFanHuiZhi = "是否启用为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiAddClass.strXiangShiFangShi))
                {
                    nret = 1;
                    strFanHuiZhi = "显示方式为空，请检查！";
                    goto PROC_EXIT;
                }
                if (string.IsNullOrEmpty(KeShiAddClass.strSuoShuYuanQu))
                {
                    nret = 1;
                    strFanHuiZhi = "所属院区为空，请检查！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 判断是否存在相同名称的科室

                List<jcsj_KeShi> ListKeShi = new SqlSugarRepository<jcsj_KeShi>(db).getByWhere(a => a.KeShiMingCheng == KeShiAddClass.strKeShiMingCheng);

                if (ListKeShi.Count != 0)
                {
                    nret = 1;
                    strFanHuiZhi = $"当前科室名称【{KeShiAddClass.strKeShiMingCheng}】已存在！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 获得顺序

                List<jcsj_KeShi> ListXinXi = new SqlSugarRepository<jcsj_KeShi>(db).getAll();

                if (ListXinXi.Count != 0)
                {
                    iShunXu = ListXinXi.Max(t => t.ShunXu) + 1;
                }
                else
                {
                    iShunXu = 1;
                }

                #endregion

                #region 执行添加数据库

                DbResult<bool> result = new SqlSugarRepository<jcsj_WeiHaiYinSuZuHeXiangMu>(db).UseTran(() =>
                {

                    jcsj_KeShi KeShi = new jcsj_KeShi();

                    KeShi.KeShiMingCheng = KeShiAddClass.strKeShiMingCheng.Trim();
                    KeShi.KeShiLeiXing = KeShiAddClass.strKeShiLeiXing.Trim();
                    KeShi.PYM = KeShiAddClass.strPYM.Trim();
                    KeShi.BeiZhu1 = KeShiAddClass.strBeiZhu1.Trim();
                    KeShi.BeiZhu2 = KeShiAddClass.strBeiZhu2.Trim();
                    KeShi.ShiFouKeYong = KeShiAddClass.strShiFouQiYong.Trim();
                    KeShi.XianShiFangShi = KeShiAddClass.strXiangShiFangShi.Trim();
                    KeShi.SuoShuYuanQu = KeShiAddClass.strSuoShuYuanQu.Trim();
                    KeShi.ShunXu = iShunXu;
                    KeShi.XiaoJieFangShi = KeShiAddClass.strXiaoJieShengChengGeShi.Trim();

                    //获取到院区前缀并且加上返回来的tid

                    string strKeShiID = YuanQuQianZhui + new SqlSugarRepository<jcsj_KeShi>(db).AddReturnIdentity(KeShi);

                    #region 执行修改语句将科室ID修改进去

                    strSql = $"update jcsj_KeShi set KeShiID='{strKeShiID}' where KeShiMingCheng='{KeShiAddClass.strKeShiMingCheng}'";

                    BolShiFouChengGong = new SqlSugarRepository<jcsj_KeShi>(db).ExecuteCommandSql(strSql);

                    if (BolShiFouChengGong == false)
                    {
                        nret = 1;
                        strFanHuiZhi = "修改科室ID失败，请检查！";
                        return;
                    }
                },
                 (ex) =>
                 {
                     nret = 1000;
                     strFanHuiZhi = ex.Message;
                     Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:事务报错异常:【{ex.Message}】");
                 });

            #endregion

            #endregion


            PROC_EXIT:
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = nret,
                    Message = strFanHuiZhi,
                    Data = ""
                });
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:报错异常:" + ex.Message);
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = 1000,
                    Message = ex.Message,
                    Data = ""
                });
            }
        }
        /// <summary>
        /// 科室维护修改
        /// </summary>
        /// <param name="KeShiUpdateClass"></param>
        /// <returns></returns>
        public string PutKeShiUpdate(KeShiUpdateClass KeShiUpdateClass)
        {
            int nret = 0; string strFanHuiZhi = ""; bool BolShiFouChengGong = false; string strSql = "";
            try
            {
                Logger.Singleton.Debug($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:接收参数【{KeShiUpdateClass}】");

                #region 数据校验

                if (string.IsNullOrEmpty(KeShiUpdateClass.strKeShiMingCheng))
                {
                    nret = 1;
                    strFanHuiZhi = "科室名称为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiUpdateClass.strKeShiLeiXing))
                {
                    nret = 1;
                    strFanHuiZhi = "科室类型为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiUpdateClass.strShiFouQiYong))
                {
                    nret = 1;
                    strFanHuiZhi = "是否启用为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiUpdateClass.strXiangShiFangShi))
                {
                    nret = 1;
                    strFanHuiZhi = "显示方式为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiUpdateClass.strSuoShuYuanQu))
                {
                    nret = 1;
                    strFanHuiZhi = "所属院区为空，请检查！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 判断是否存在相同科室名称

                List<jcsj_KeShi> ListKeShi = new SqlSugarRepository<jcsj_KeShi>(db).getByWhere(a => a.KeShiMingCheng == KeShiUpdateClass.strKeShiMingCheng && a.KeShiID != KeShiUpdateClass.strKeShiID);

                if (ListKeShi.Count != 0)
                {
                    nret = 1;
                    strFanHuiZhi = $"当前科室名称【{KeShiUpdateClass.strKeShiMingCheng}】已存在！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 执行修改操作

                strSql = $@"update jcsj_KeShi set KeShiMingCheng='{KeShiUpdateClass.strKeShiMingCheng}',KeShiLeiXing='{KeShiUpdateClass.strKeShiLeiXing}',PYM='{KeShiUpdateClass.strPYM}',BeiZhu1='{KeShiUpdateClass.strBeiZhu1}',BeiZhu2='{KeShiUpdateClass.strBeiZhu2}',
ShiFouKeYong='{KeShiUpdateClass.strShiFouQiYong}',XianShiFangShi='{KeShiUpdateClass.strXiangShiFangShi}',SuoShuYuanQu='{KeShiUpdateClass.strSuoShuYuanQu}',XiaoJieFangShi='{KeShiUpdateClass.strXiaoJieShengChengGeShi}'
where KeShiID='{KeShiUpdateClass.strKeShiID}'";

                BolShiFouChengGong = new SqlSugarRepository<jcsj_KeShi>(db).ExecuteCommandSql(strSql);

                if (BolShiFouChengGong == false)
                {
                    nret = 1;
                    strFanHuiZhi = "修改科室失败，请检查！";
                    goto PROC_EXIT;
                }
            #endregion


            PROC_EXIT:
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = nret,
                    Message = strFanHuiZhi,
                    Data = ""
                });
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:报错异常:" + ex.Message);
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = 1000,
                    Message = ex.Message,
                    Data = ""
                });
            }
        }
        public string PostKeShiZhongDaJiBingAdd(KeShiZhongDaJiBingAddClass KeShiZhongDaJiBingAddClass)
        {
            int nret = 0; string strFanHuiZhi = ""; bool BolShiFouChengGong = false;
            try
            {
                Logger.Singleton.Debug($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:接收参数【{KeShiZhongDaJiBingAddClass}】");

                #region 数据校验

                if (string.IsNullOrEmpty(KeShiZhongDaJiBingAddClass.strKeShiID))
                {
                    nret = 1;
                    strFanHuiZhi = "科室ID为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiZhongDaJiBingAddClass.strJiBingMingCheng))
                {
                    nret = 1;
                    strFanHuiZhi = "疾病名称为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiZhongDaJiBingAddClass.strJiBingLeiBie))
                {
                    nret = 1;
                    strFanHuiZhi = "疾病类别为空，请检查！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 判断是否存在重复数据

                List<jcsj_KeShiZhongDaJiBingMuBan> KeShiZhongDaJiBing = new SqlSugarRepository<jcsj_KeShiZhongDaJiBingMuBan>(db).getByWhere(a => a.KeShiID == KeShiZhongDaJiBingAddClass.strKeShiID
                && a.JiBingMingCheng == KeShiZhongDaJiBingAddClass.strJiBingMingCheng && a.JiBingLeiBie == KeShiZhongDaJiBingAddClass.strJiBingLeiBie);

                if (KeShiZhongDaJiBing.Count != 0)
                {
                    nret = 1;
                    strFanHuiZhi = $"当前科室重大疾病模板名称【{KeShiZhongDaJiBingAddClass.strJiBingMingCheng}】已存在！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 执行新增操作

                jcsj_KeShiZhongDaJiBingMuBan ZhongDaJiBingMuBan = new jcsj_KeShiZhongDaJiBingMuBan();

                ZhongDaJiBingMuBan.KeShiID = KeShiZhongDaJiBingAddClass.strKeShiID;
                ZhongDaJiBingMuBan.JiBingMingCheng = KeShiZhongDaJiBingAddClass.strJiBingMingCheng;
                ZhongDaJiBingMuBan.ZhongYaoYiChangJieGuo = KeShiZhongDaJiBingAddClass.strZhongDaYiChangJieGuo;
                ZhongDaJiBingMuBan.JiBingLeiBie = KeShiZhongDaJiBingAddClass.strJiBingLeiBie;

                BolShiFouChengGong = new SqlSugarRepository<jcsj_KeShiZhongDaJiBingMuBan>(db).Add(ZhongDaJiBingMuBan);
                if (BolShiFouChengGong == false)
                {
                    nret = 1;
                    strFanHuiZhi = "添加科室重大疾病模板出现错误，请检查！";
                    goto PROC_EXIT;
                }

            #endregion


            PROC_EXIT:
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = nret,
                    Message = strFanHuiZhi,
                    Data = ""
                });
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:报错异常:" + ex.Message);
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = 1000,
                    Message = ex.Message,
                    Data = ""
                });
            }
        }
        /// <summary>
        /// 科室重大疾病模板删除
        /// </summary>
        /// <param name="KeShiZhongDaJiBingDelClass"></param>
        /// <returns></returns>
        public string DeleteKeShiZhongDaJiBingDel(KeShiZhongDaJiBingDelClass KeShiZhongDaJiBingDelClass)
        {
            int nret = 0; string strFanHuiZhi = ""; bool BolShiFouChengGong = false;
            try
            {
                Logger.Singleton.Debug($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:接收参数【{KeShiZhongDaJiBingDelClass}】");

                #region 数据校验

                if (string.IsNullOrEmpty(KeShiZhongDaJiBingDelClass.strKeShiID))
                {
                    nret = 1;
                    strFanHuiZhi = "科室ID为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiZhongDaJiBingDelClass.strJiBingMingCheng))
                {
                    nret = 1;
                    strFanHuiZhi = "疾病名称为空，请检查！";
                    goto PROC_EXIT;
                }

                if (string.IsNullOrEmpty(KeShiZhongDaJiBingDelClass.strJiBingLeiBie))
                {
                    nret = 1;
                    strFanHuiZhi = "疾病类别为空，请检查！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 执行删除

                BolShiFouChengGong = new SqlSugarRepository<jcsj_KeShiZhongDaJiBingMuBan>(db).DeleteWhere(A => A.KeShiID == KeShiZhongDaJiBingDelClass.strKeShiID &&
                A.JiBingMingCheng == KeShiZhongDaJiBingDelClass.strJiBingMingCheng && A.JiBingLeiBie == KeShiZhongDaJiBingDelClass.strJiBingLeiBie);
                if (BolShiFouChengGong == false)
                {
                    nret = 1;
                    strFanHuiZhi = "重大疾病模板删除失败，请检查!";
                    goto PROC_EXIT;
                }

            #endregion


            PROC_EXIT:
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = nret,
                    Message = strFanHuiZhi,
                    Data = ""
                });
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:报错异常:" + ex.Message);
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = 1000,
                    Message = ex.Message,
                    Data = ""
                });
            }
        }
        /// <summary>
        /// 科室重大疾病模板查询
        /// </summary>
        /// <param name="strKeShiID"></param>
        /// <returns></returns>
        public string GetKeShiZhongDaJiBingSel(string strKeShiID)
        {
            int nret = 0; string strFanHuiZhi = ""; string strSql = ""; List<object> LKeShiZhongDaJiBingMuBan = new List<object>();
            try
            {
                Logger.Singleton.Debug($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:接收参数【{strKeShiID}】");

                #region 数据校验

                if (string.IsNullOrEmpty(strKeShiID))
                {
                    nret = 1;
                    strFanHuiZhi = "科室ID为空，请检查！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 执行查询

                strSql = $"select * from jcsj_KeShiZhongDaJiBingMuBan where KeShiID='{strKeShiID}'";

                LKeShiZhongDaJiBingMuBan = new SqlSugarRepository<object>(db).getListBySql(strSql);

            #endregion


            PROC_EXIT:
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = nret,
                    Message = strFanHuiZhi,
                    Data = LKeShiZhongDaJiBingMuBan
                });
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:报错异常:" + ex.Message);
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = 1000,
                    Message = ex.Message,
                    Data = ""
                });
            }
        }
        /// <summary>
        /// 科室维护查询
        /// </summary>
        /// <param name="strYuanQuMingCheng"></param>
        /// <returns></returns>
        public string GetKeShiSel(string YuanQu)
        {
            int nret = 0; string strFanHuiZhi = ""; string strSql = ""; List<object> LKeShi = new List<object>();
            try
            {
                Logger.Singleton.Debug($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:接收参数【{YuanQu}】");

                #region 数据校验

                if (string.IsNullOrEmpty(YuanQu))
                {
                    nret = 1;
                    strFanHuiZhi = "关键字为空，请检查！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 执行查询

                strSql = $"select * from jcsj_KeShi where SuoShuYuanQu like'%{YuanQu}%' order by ShunXu";

                LKeShi = new SqlSugarRepository<object>(db).getListBySql(strSql);

            #endregion


            PROC_EXIT:
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = nret,
                    Message = strFanHuiZhi,
                    Data = LKeShi
                });
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:报错异常:" + ex.Message);
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = 1000,
                    Message = ex.Message,
                    Data = ""
                });
            }
        }
        /// <summary>
        /// 科室维护删除
        /// </summary>
        /// <param name="strKeShiID"></param>
        /// <returns></returns>
        public string DeleteKeShiDel(string strKeShiID)
        {
            ;
            int nret = 0; string strFanHuiZhi = ""; bool BolShiFouChengGong = false; string strSql = "";
            try
            {
                Logger.Singleton.Debug($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:接收参数【{strKeShiID}】");

                #region 数据校验

                if (string.IsNullOrEmpty(strKeShiID))
                {
                    nret = 1;
                    strFanHuiZhi = "科室ID为空，请检查！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 若科室下存在申请单则不允许删除

                List<jcsj_ShenQingDan> ShenQingDan = new SqlSugarRepository<jcsj_ShenQingDan>(db).getByWhere(a => a.KeShiID == strKeShiID);

                if (ShenQingDan.Count != 0)
                {
                    nret = 1;
                    strFanHuiZhi = $"当前科室已有申请单已存在，不允许删除！";
                    goto PROC_EXIT;
                }

                #endregion

                #region 执行删除

                BolShiFouChengGong = new SqlSugarRepository<jcsj_KeShi>(db).DeleteWhere(A => A.KeShiID == strKeShiID);
                if (BolShiFouChengGong == false)
                {
                    nret = 1;
                    strFanHuiZhi = "科室删除失败，请检查!";
                    goto PROC_EXIT;
                }

            #endregion


            PROC_EXIT:
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = nret,
                    Message = strFanHuiZhi,
                    Data = ""
                });
            }
            catch (Exception ex)
            {
                Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:报错异常:" + ex.Message);
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = 1000,
                    Message = ex.Message,
                    Data = ""
                });
            }
        }
        /// <summary>
        /// 查询院区
        /// </summary>
        /// <returns></returns>
        public string GetYuanQuMingCheng()
        {
            int nret = 0; string strFanHuiZhi = ""; string strSql = "";
            try
            {
                Logger.Singleton.Debug($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】");

                List<jcsj_YuanQu> Listjcsj_YuanQu = new SqlSugarRepository<jcsj_YuanQu>(db).getAll().OrderBy(t => t.ShunXu).ToList();

                List<string> ListYuanQu = Listjcsj_YuanQu.Select(t => t.YuanQuMingCheng).ToList();


            PROC_EXIT:
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = nret,
                    Message = strFanHuiZhi,
                    Data = ListYuanQu
                });
            }

            catch (Exception ex)
            {
                Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:报错异常:" + ex.Message);
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = 1000,
                    Message = ex.Message,
                    Data = ""
                });
            }
        }
        /// <summary>
        /// 调整顺序
        /// </summary>
        /// <param name="iQianShunXu"></param>
        /// <param name="iHouShunXu"></param>
        /// <param name="strKeShiId"></param>
        /// <returns></returns>
        public string PutTiaoZhengShunXu(int iQianShunXu, int iHouShunXu, string strKeShiId)
        {
            int nret = 0; string strFanHuiZhi = ""; string strSql = ""; bool BolShiFouChengGong = false;
            try
            {
                Logger.Singleton.Debug($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:接收参数【{iQianShunXu},{iHouShunXu}】");

                //先修改要调整科室的顺序
                if (new SqlSugarRepository<jcsj_KeShi>(db).Update(t => new jcsj_KeShi
                {
                    ShunXu = iHouShunXu
                }, t => t.KeShiID == strKeShiId) == false)
                {
                    nret = 1;
                    strFanHuiZhi = "修改科室顺序失败，请检查！";
                    goto PROC_EXIT;
                }
                Expression<Func<jcsj_KeShi, jcsj_KeShi>> columns;
                Expression<Func<jcsj_KeShi, bool>> expression;
                //当修改前顺序小于修改后顺序时
                if (iQianShunXu < iHouShunXu)
                {
                    //修改顺序减1
                    columns = t => new jcsj_KeShi
                    {
                        ShunXu = t.ShunXu - 1,
                    };
                    //条件为顺序字段大于等于修改前顺序并且小于等于修改后顺序并且不等于要修改的
                    expression = t => t.ShunXu >= iQianShunXu && t.ShunXu <= iHouShunXu && t.KeShiID != strKeShiId;
                }
                //当修改前顺序大于修改后顺序时
                else if (iQianShunXu > iHouShunXu)
                {
                    //修改顺序加1
                    columns = t => new jcsj_KeShi
                    {
                        ShunXu = t.ShunXu + 1,
                    };
                    //条件为顺序字段小于等于修改前顺序并且大于等于修改后顺序并且不等于要修改的
                    expression = t => t.ShunXu <= iQianShunXu && t.ShunXu >= iHouShunXu && t.KeShiID != strKeShiId;
                }
                else
                {
                    nret = 1;
                    strFanHuiZhi = "调整前后顺序一致！";
                    goto PROC_EXIT;
                }

                if (new SqlSugarRepository<jcsj_KeShi>(db).Update(columns, expression) == false)
                {
                    nret = 1;
                    strFanHuiZhi = "修改科室顺序失败，请检查！";
                    goto PROC_EXIT;
                }


            PROC_EXIT:
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = nret,
                    Message = strFanHuiZhi,
                    Data = ""
                });
            }

            catch (Exception ex)
            {
                Logger.Singleton.Error($@"【{System.Reflection.MethodBase.GetCurrentMethod().Name}】:报错异常:" + ex.Message);
                return JsonConvert.SerializeObject(new ApiResult<object>()
                {
                    Success = 1000,
                    Message = ex.Message,
                    Data = ""
                });
            }
        }
    }
}
